#include "generic_cleaner.hpp"
#include "symtable.hpp"
#include "ast.hpp"

Node* GenericCleaner::visit(Node* n) {
    n->accept(this);
    return n;
}

Node* GenericCleaner::visit(FuncDefNode* n) {
    if (n->sym_table()) {
        n->sym_table()->clear_instantiation();
    }

    visit(n->args());
    visit(n->body());

    return n;
}

Node* GenericCleaner::visit(ListNode* n) {
    for (auto it = n->node_list()->begin();
        it != n->node_list()->end(); it++) {
        visit(*it);
    }

    return n;
}

Node* GenericCleaner::visit(StmtsNode* n) {
    for (auto it = n->node_list()->begin();
        it != n->node_list()->end(); it++) {
        visit(*it);
    }

    return n;
}
